package com.slz3.business.module.systemManagement.sysFunction.domain;

import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.util.UUIDUtils;
import com.slz3.business.frame.util.VE;

import java.time.LocalDateTime;

public class SysFunctionFactory {

    /**
     * 初始化基础属性值
     */
    public static SysFunction initBaseFields(SysFunction sysFunction) {
        if (sysFunction.getUuid() == null) {
            sysFunction.setUuid(UUIDUtils.generateUUID());
            sysFunction.setCreateTime(LocalDateTime.now());
            if (VE.isEmpty(sysFunction.getSerAudit())) {
                sysFunction.setSerAudit(AuditFlag.WAIT_SUBMIT);
            }
            if (VE.isEmpty(sysFunction.getSerUsing())) {
                sysFunction.setSerUsing(UsingFlag.ENABLE);
            }
        } else {
            sysFunction.setLastModifyTime(LocalDateTime.now());
        }
        return sysFunction;
    }

    /**
     * 初始化基础属性值
     */
    public static SysFunction initBaseFields() {
        return initBaseFields(newTemStyle());
    }

    public static SysFunction newTemStyle() {
        return new SysFunction();
    }

}
